﻿@model Eqwww.Web.Areas.SystemManage.Models.Post.EditViewModel

@{
    ViewData["Title"] = "Edit";
    Layout = "~/Views/Shared/_ManageFormLayout.cshtml";
}


<form id="form1" class="mdui-m-t-3 mdui-m-b-3">
    <div asp-validation-summary="ModelOnly" class="mdui-textfield-error"></div>
    <input asp-for="Id" type="hidden" />
    <div class="mdui-container">

        <div class="mdui-row">

            <div class="mdui-col-xs-12 mdui-col-md-6">

                <div class="mdui-textfield mdui-textfield-floating-label">
                    <label asp-for="Code" class="mdui-textfield-label"></label>
                    <input asp-for="Code" class="mdui-textfield-input mdui-color-grey-100" />
                    <span asp-validation-for="Code" class="mdui-textfield-error"></span>
                </div>
            </div>
            <div class="mdui-col-xs-12 mdui-col-md-6">
                <div class="mdui-textfield mdui-textfield-floating-label">
                    <label asp-for="Name" class="mdui-textfield-label"></label>
                    <input asp-for="Name" class="mdui-textfield-input mdui-color-grey-100" />
                    <span asp-validation-for="Name" class="mdui-textfield-error"></span>
                </div>
            </div>

            <div class="mdui-col-xs-12 mdui-col-md-6 ">
                <div class="mdui-textfield">
                    <label asp-for="OrganizeId" class="mdui-textfield-label"></label>
                    <input type="hidden" asp-for="OrganizeId" />
                    <input asp-for="OrganizeName" readonly="readonly" class="mdui-textfield-input" placeholder="==请选择==" />
                    <i class="mdui-icon material-icons" style="position:absolute;right:0;">arrow_drop_down</i>
                    <span asp-validation-for="OrganizeName" class="mdui-textfield-error"></span>
                </div>
            </div>

            <div class="mdui-col-xs-12 mdui-col-md-6">
                <div class="mdui-textfield">
                    <label asp-for="JobId" class="mdui-textfield-label"></label>
                    <input type="hidden" asp-for="JobId" />
                    <input asp-for="JobName" readonly="readonly" class="mdui-textfield-input" placeholder="==请选择==" />
                    <i class="mdui-icon material-icons" style="position:absolute;right:0;">arrow_drop_down</i>
                    <span asp-validation-for="JobName" class="mdui-textfield-error"></span>
                </div>
            </div>

            <div class="mdui-col-xs-12 mdui-col-md-6">
                <div class="mdui-textfield">
                    <label asp-for="ParentId" class="mdui-textfield-label"></label>
                    <input type="hidden" asp-for="ParentId" />
                    <input asp-for="ParentName" readonly="readonly" class="mdui-textfield-input" placeholder="==请选择==" />
                    <i class="mdui-icon material-icons" style="position:absolute;right:0;">arrow_drop_down</i>
                    <span asp-validation-for="ParentName" class="mdui-textfield-error"></span>
                </div>
            </div>


            <div class="mdui-col-xs-12 mdui-col-md-6">
                <div class="mdui-textfield mdui-textfield-floating-label">
                    <label asp-for="SortCode" class="mdui-textfield-label"></label>
                    <input asp-for="SortCode"  class="mdui-textfield-input mdui-color-grey-100" />
                    <span asp-validation-for="SortCode" class="mdui-textfield-error"></span>
                </div>
            </div>

        </div>

    </div>
</form>

@section Scripts {
    @{await Html.RenderPartialAsync("_ValidationScriptsPartial");}

    <script>

        $(function () {
            $('#OrganizeName').SelectDown({
                url: '/SystemManage/Organize/TreeCollapse?HideTopNode=True',
                success: function (layero, index) {
                    var iframeWin = top.window[layero.find('iframe')[0]['name']];
                    iframeWin.$('.eq-choose').unbind().bind('click', function (e) {
                        e.preventDefault();
                        e.stopPropagation();
                        $('#OrganizeId').val($(this).parent().attr('data-id'));
                        $('#OrganizeName').val($(this).parent().attr('data-name'));
                        top.layer.close(index);

                    });
                }
            });

            $('#JobName').SelectDown({
                url: '/SystemManage/Job/TreeCollapse',
                success: function (layero, index) {
                    var iframeWin = top.window[layero.find('iframe')[0]['name']];
                    iframeWin.$('.eq-choose').unbind().bind('click', function (e) {
                        e.preventDefault();
                        e.stopPropagation();
                        $('#JobId').val($(this).parent().attr('data-id'));
                        $('#JobName').val($(this).parent().attr('data-name'));
                        top.layer.close(index);
                    });
                }
            });

            $('#ParentName').SelectDown({
                url: '/SystemManage/Post/TreeCollapse',
                success: function (layero, index) {
                    var iframeWin = top.window[layero.find('iframe')[0]['name']];
                    iframeWin.$('.eq-choose').unbind().bind('click', function (e) {
                        e.preventDefault();
                        e.stopPropagation();
                        $('#ParentId').val($(this).parent().attr('data-id'));
                        $('#ParentName').val($(this).parent().attr('data-name'));
                        top.layer.close(index);
                    });
                }
            });
        });


        function submitForm() {

            if (!$("#form1").valid()) {
                return false;
            }
            var postData = $('#form1').formSerialize();

            $.submitForm({
                url: "/SystemManage/Post/Edit",
                param: postData,
                success: function () {
                    $.currentWindow().location.reload();
                }
            });

        };
    </script>
}
